<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="prev" href="module-curses.textpad.html" />
<link rel="parent" href="module-curses.textpad.html" />
<link rel="next" href="module-curses.wrapper.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>14.8.1 Textbox objects </title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="14.8 curses.textpad  "
  href="module-curses.textpad.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="14.8 curses.textpad  "
  href="module-curses.textpad.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="14.9 curses.wrapper  "
  href="module-curses.wrapper.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.textpad.html">14.8 curses.textpad  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-curses.textpad.html">14.8 curses.textpad  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-curses.wrapper.html">14.9 curses.wrapper  </a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h2><a name="SECTION0016810000000000000000"></a><a name="curses-textpad-objects"></a>
<br>
14.8.1 Textbox objects 
</h2>

<p>
You can instantiate a <tt class="class">Textbox</tt> object as follows:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><span class="typelabel">class</span>&nbsp;<tt id='l2h-3120' xml:id='l2h-3120' class="class">Textbox</tt></b>(</nobr></td>
  <td><var>win</var>)</td></tr></table></dt>
<dd>
Return a textbox widget object.  The <var>win</var> argument should be a
curses <tt class="class">WindowObject</tt> in which the textbox is to be contained.
The edit cursor of the textbox is initially located at the upper left
hand corner of the containing window, with coordinates <code>(0, 0)</code>.
The instance's <tt class="member">stripspaces</tt> flag is initially on.
</dl>

<p>
<tt class="class">Textbox</tt> objects have the following methods:

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3121' xml:id='l2h-3121' class="method">edit</tt></b>(</nobr></td>
  <td><var></var><big>[</big><var>validator</var><big>]</big><var></var>)</td></tr></table></dt>
<dd>
This is the entry point you will normally use.  It accepts editing
keystrokes until one of the termination keystrokes is entered.  If
<var>validator</var> is supplied, it must be a function.  It will be called
for each keystroke entered with the keystroke as a parameter; command
dispatch is done on the result. This method returns the window
contents as a string; whether blanks in the window are included is
affected by the <tt class="member">stripspaces</tt> member.
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3122' xml:id='l2h-3122' class="method">do_command</tt></b>(</nobr></td>
  <td><var>ch</var>)</td></tr></table></dt>
<dd>
Process a single command keystroke.  Here are the supported special
keystrokes: 

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Keystroke</th>
      <th class="left"  >Action</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-A</tt></td>
        <td class="left"  >Go to left edge of window.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-B</tt></td>
        <td class="left"  >Cursor left, wrapping to previous line if appropriate.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-D</tt></td>
        <td class="left"  >Delete character under cursor.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-E</tt></td>
        <td class="left"  >Go to right edge (stripspaces off) or end of line
                  (stripspaces on).</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-F</tt></td>
        <td class="left"  >Cursor right, wrapping to next line when appropriate.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-G</tt></td>
        <td class="left"  >Terminate, returning the window contents.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-H</tt></td>
        <td class="left"  >Delete character backward.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-J</tt></td>
        <td class="left"  >Terminate if the window is 1 line, otherwise
                     insert newline.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-K</tt></td>
        <td class="left"  >If line is blank, delete it, otherwise clear to
                     end of line.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-L</tt></td>
        <td class="left"  >Refresh screen.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-N</tt></td>
        <td class="left"  >Cursor down; move down one line.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-O</tt></td>
        <td class="left"  >Insert a blank line at cursor location.</td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">Control-P</tt></td>
        <td class="left"  >Cursor up; move up one line.</td></tr></tbody>
</table></div>

<p>
Move operations do nothing if the cursor is at an edge where the
movement is not possible.  The following synonyms are supported where
possible:

<p>
<div class="center"><table class="realtable">
  <thead>
    <tr>
      <th class="left"  >Constant</th>
      <th class="left"  >Keystroke</th>
      </tr>
    </thead>
  <tbody>
    <tr><td class="left"   valign="baseline"><tt class="constant">KEY_LEFT</tt></td>
        <td class="left"  ><kbd>Control-B</kbd></td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">KEY_RIGHT</tt></td>
        <td class="left"  ><kbd>Control-F</kbd></td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">KEY_UP</tt></td>
        <td class="left"  ><kbd>Control-P</kbd></td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">KEY_DOWN</tt></td>
        <td class="left"  ><kbd>Control-N</kbd></td></tr>
    <tr><td class="left"   valign="baseline"><tt class="constant">KEY_BACKSPACE</tt></td>
        <td class="left"  ><kbd>Control-h</kbd></td></tr></tbody>
</table></div>

<p>
All other keystrokes are treated as a command to insert the given
character and move right (with line wrapping).
</dl>

<p>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-3123' xml:id='l2h-3123' class="method">gather</tt></b>(</nobr></td>
  <td><var></var>)</td></tr></table></dt>
<dd>
This method returns the window contents as a string; whether blanks in
the window are included is affected by the <tt class="member">stripspaces</tt>
member.
</dl>

<p>
<dl><dt><b><tt id='l2h-3124' xml:id='l2h-3124' class="member">stripspaces</tt></b></dt>
<dd>
This data member is a flag which controls the interpretation of blanks in
the window.  When it is on, trailing blanks on each line are ignored;
any cursor motion that would land the cursor on a trailing blank goes
to the end of that line instead, and trailing blanks are stripped when
the window contents are gathered.
</dl>

<p>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="14.8 curses.textpad  "
  href="module-curses.textpad.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="14.8 curses.textpad  "
  href="module-curses.textpad.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="14.9 curses.wrapper  "
  href="module-curses.wrapper.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.textpad.html">14.8 curses.textpad  </a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="module-curses.textpad.html">14.8 curses.textpad  </a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-curses.wrapper.html">14.9 curses.wrapper  </a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
